/*
【例2】设计一个抽象类Vehicle，其中包含2个纯虚函数setdata()和show()；
由它派生出类Car和类Truck，类Car包含名称、颜色、载客数3个数据成员，类Truck包含名称、颜色、载重量3个数据成员。
*/

#include <iostream>
#include <string>

using namespace std;

class Vehicle {
protected:
	string name;
	string color;
	int container_passenger;
	int container_good;

public :
	virtual void setdata(string name, string color, int container) = 0;
	virtual void show() = 0;
};

class Car: public Vehicle {
	private:
		int container_passenger;

	public:
		void setdata(string name, string color, int container) {
			this->name = name;
			this->color = color;
			this->container_passenger = container;
		}

		void show() {
			cout << "This is a Car." << endl;
			cout << "Name: " << name << endl;
			cout << "Color: "<< color << endl;
			cout << "Container_Passenger: " << container_passenger << " people.";
			cout << endl;
		}
};

class Truck: public Vehicle {
	private:
		int container_good;

	public:
		void setdata(string name, string color, int container) {
			this->name = name;
			this->color = color;
			this->container_good = container;
		}

		void show() {
			cout << "This is a Truck." << endl;
			cout << "Name: " << name << endl;
			cout << "Color: "<< color << endl;
			cout << "Container_Passenager: " << container_good << "kg.";
			cout << endl;
		}
};


int main(int argc, char * argv[]) {
	Vehicle * p;
	Car c;
	Truck t;

	p = &c;
	p->setdata("Automobili Lamborghini S.p.A", "Red", 4);
	p->show();

	p = &t;
	p->setdata("Ferrar", "Green", 100);
	p->show();

	return 0;
}
